#ifndef _KERNEL_DEFS_H_
#define _KERNEL_DEFS_H_

// System call IDs
#define HARDWARE_INTERRUPT      0xFF
#define SYSCALL_CREATE          0
#define SYSCALL_MY_TID          1
#define SYSCALL_MY_PARENT_TID   2
#define SYSCALL_PASS            3
#define SYSCALL_EXIT            4
#define SYSCALL_FINGER_OF_DEATH 5
#define SYSCALL_SEND            6
#define SYSCALL_RECEIVE         7
#define SYSCALL_REPLY           8
#define SYSCALL_REGISTER_AS     9
#define SYSCALL_WHO_IS          10
#define SYSCALL_AWAIT_EVENT     11
#define SYSCALL_DELAY           12
#define SYSCALL_TIME            13
#define SYSCALL_DELAY_UNTIL     14
#define SYSCALL_GETC            15
#define SYSCALL_PUTC            16
#define SYSCALL_PARAM_TEST      17
#define SYSCALL_PANIC           18
#define SYSCALL_NOTIFY_EVENT    19

// Event types
#define EVENT_NONE          -1
#define EVENT_TIMER         0
#define EVENT_UART1_RX      1
#define EVENT_UART1_TX      2
#define EVENT_UART2_RX      3
#define EVENT_UART2_TX      4
#define EVENT_NEW_SENSOR    5
#define EVENT_LANDMARK      6
#define EVENT_FREE_RESOURCE 7
#define EVENT_MAX           8

// Task thread states
#define STATE_DEFUNCT       0
#define STATE_READY         1
#define STATE_ACTIVE        2
#define STATE_SEND_BLOCK    3
#define STATE_RECEIVE_BLOCK 4
#define STATE_REPLY_BLOCK   5
#define STATE_EVENT_BLOCK   6

// Common errors
#define SUCCESS										0
#define ERROR_NULL_POINTER				-10

// Constants
#define MAX_TASKS     50
#define MAX_PRI       10
#define MAX_NAME_LEN  20

#define CODE_BASE       0x218000  // address where kernel is loaded
#define STACK_SIZE      0x80000   // 512 kB

// NULL pointer
#define NULL 0

// Booleans
#define TRUE  1
#define FALSE 0

// Interrupt modes
#define SWI 0
#define IRQ 1

// Window bounds
#define LINES   24
#define COLUMNS 80

// Critical sections
#define SECTION_TRAIN_TX      0
#define SECTION_TERMINAL_TX   1
#define MAX_SECTIONS 2

// Interrupt masks
#define TIMER3_IRQ  0x80000
#define UART1_IRQ   0x100000
#define UART2_IRQ   0x400000

// Timing stuff
#define TICKS_PER_SEC 20
#define UM_PER_MM 10
#define UNDEFINED   -1
#define INFINITY    1000000


#endif
